- page_title "Members"

.group-members-page.prepend-top-default
  - if current_user && can?(current_user, :admin_group_member, @group)
    .panel.panel-default
      .panel-heading
        Add new user to group
      .panel-body
        %p.light
          Members of group have access to all group projects.
        .new-group-member-holder
          = render "new_group_member"

  - if current_user && @group.ldap_synced?
    .bs-callout.bs-callout-info
      The members of this group are managed using LDAP and cannot be added, changed or removed here.
      Because LDAP permissions in GitLab get updated one user at a time and because GitLab caches LDAP check results, changes on your LDAP server or in this group's LDAP sync settings may take up to #{Gitlab.config.ldap['sync_time']}s to show in the list below.
      %ul
        - @group.ldap_group_links.each do |ldap_group_link|
          %li
            People in cn
            %code= ldap_group_link.cn
            are given
            %code= ldap_group_link.human_access
            access.
      - if can?(current_user, :admin_group_member, @group)
        = form_tag(reset_access_group_ldap_path(@group), method: :put, class: 'inline') do
          = button_to 'Clear LDAP permission cache', '#', class: "btn btn-remove js-confirm-danger",
            data: { "confirm-danger-message" => clear_ldap_permission_cache_message,
                    'warning-message' => 'If you made manual permission tweaks for some group members they will be lost.' }


  - if current_user && can?(current_user, :admin_group_member, @group)
    = render 'shared/members/requests', membership_source: @group, members: @members.request

  .panel.panel-default
    .panel-heading
      %strong #{@group.name}
      group members
      %small
        (#{@members.total_count})
      .controls
        = form_tag group_group_members_path(@group), method: :get, class: 'form-inline member-search-form'  do
          .form-group
            = search_field_tag :search, params[:search], { placeholder: 'Find existing member by name', class: 'form-control', spellcheck: false }
          = button_tag class: 'btn', title: 'Search' do
            = icon("search")
    %ul.content-list
      = render partial: 'shared/members/member', collection: @members.non_request, as: :member
    = paginate @members.non_request, theme: 'gitlab'

:javascript
  $('form.member-search-form').on('submit', function(event) {
    event.preventDefault();
    Turbolinks.visit(this.action + '?' + $(this).serialize());
  });

= render 'shared/confirm_modal', phrase: 'reset'
